feat: add nextjs-app example template#74
Conversation
Greptile SummaryAdds a
Confidence Score: 4/5Safe to merge; the template is self-contained and the changes to shared files (init.rs, workspace yaml, README) are minimal and low-risk. The template is well-structured and the standalone output + Dockerfile pattern works as described. The main gap is that Docker builds install dependencies without a lock file on every release, which can drift silently over time. A missing start script is a minor usability omission. examples/nextjs-app/Dockerfile and examples/nextjs-app/package.json are worth a second look for the lock-file and start-script gaps.
|
| Filename | Overview |
|---|---|
| examples/nextjs-app/Dockerfile | Multi-stage build using Next.js standalone output; build stage runs npm install without a lock file because package-lock.json is gitignored, making Docker builds non-deterministic. |
| examples/nextjs-app/alien.ts | Defines a single Container with cpu/memory/port/expose/environment matching the Dockerfile; platform list and empty permission profile look correct. |
| examples/nextjs-app/package.json | Dependencies look correct; missing a start script to run the standalone output locally, which leaves a usability gap for local production testing. |
| examples/nextjs-app/next.config.ts | Minimal config with output standalone enabled, which is required for the Dockerfile to produce a self-contained server.js. |
| crates/alien-cli/src/commands/init.rs | One-line addition to KNOWN_TEMPLATES fallback; description is consistent with template.toml and README. |
| examples/nextjs-app/app/api/health/route.ts | Minimal GET handler returning status ok; correct App Router Route Handler syntax. |
| examples/nextjs-app/.dockerignore | Excludes node_modules, .next, and alien-specific files from the Docker build context; looks correct. |
Sequence Diagram
sequenceDiagram
participant User
participant AlienCLI
participant Docker
participant CloudProvider
User->>AlienCLI: alien init nextjs-app
AlienCLI-->>User: scaffold files (Dockerfile, alien.ts, app/)
User->>AlienCLI: alien release
AlienCLI->>Docker: build (multi-stage)
Docker->>Docker: Stage 1 – npm install + next build
Docker->>Docker: Stage 2 – copy .next/standalone + static + public
Docker-->>AlienCLI: image tagged and pushed
User->>AlienCLI: alien deploy production --platform aws
AlienCLI->>CloudProvider: provision Container + HTTPS load balancer
CloudProvider-->>User: public URL (HTTPS)
User->>CloudProvider: GET /api/health
CloudProvider-->>User: "{status: ok}"
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
examples/nextjs-app/Dockerfile:3-4
**Non-deterministic dependency installs in Docker build**
`package-lock.json` is listed in the template's `.gitignore`, so the file is never committed and therefore never present when `alien release` builds this image. `COPY package-lock.json* ./` silently copies nothing, and `npm install` then resolves semver ranges at build time, meaning successive `alien release` runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a `package-lock.json` for the example (removing it from the example's `.gitignore`), or switching the build stage to pnpm so it shares the workspace lock file.
### Issue 2 of 2
examples/nextjs-app/package.json:6-7
**Missing `start` script for local production testing**
The Dockerfile runs `node server.js` directly, but there is no `start` script for users who want to preview the standalone output locally before deploying. Without it, users must know to run `node .next/standalone/server.js` manually. A `start` script keeps parity with the README's `npm install && npm run dev` workflow and matches community expectations for Next.js projects.
```suggestion
"dev": "next dev",
"build": "next build",
"start": "node .next/standalone/server.js"
```
Reviews (1): Last reviewed commit: "feat: add nextjs-app example template" | Re-trigger Greptile
| COPY package.json package-lock.json* ./ | ||
| RUN npm install |
There was a problem hiding this comment.
Non-deterministic dependency installs in Docker build
package-lock.json is listed in the template's .gitignore, so the file is never committed and therefore never present when alien release builds this image. COPY package-lock.json* ./ silently copies nothing, and npm install then resolves semver ranges at build time, meaning successive alien release runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a package-lock.json for the example (removing it from the example's .gitignore), or switching the build stage to pnpm so it shares the workspace lock file.
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/nextjs-app/Dockerfile
Line: 3-4
Comment:
**Non-deterministic dependency installs in Docker build**
`package-lock.json` is listed in the template's `.gitignore`, so the file is never committed and therefore never present when `alien release` builds this image. `COPY package-lock.json* ./` silently copies nothing, and `npm install` then resolves semver ranges at build time, meaning successive `alien release` runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a `package-lock.json` for the example (removing it from the example's `.gitignore`), or switching the build stage to pnpm so it shares the workspace lock file.
How can I resolve this? If you propose a fix, please make it concise.| "dev": "next dev", | ||
| "build": "next build" |
There was a problem hiding this comment.
Missing
start script for local production testing
The Dockerfile runs node server.js directly, but there is no start script for users who want to preview the standalone output locally before deploying. Without it, users must know to run node .next/standalone/server.js manually. A start script keeps parity with the README's npm install && npm run dev workflow and matches community expectations for Next.js projects.
| "dev": "next dev", | |
| "build": "next build" | |
| "dev": "next dev", | |
| "build": "next build", | |
| "start": "node .next/standalone/server.js" |
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/nextjs-app/package.json
Line: 6-7
Comment:
**Missing `start` script for local production testing**
The Dockerfile runs `node server.js` directly, but there is no `start` script for users who want to preview the standalone output locally before deploying. Without it, users must know to run `node .next/standalone/server.js` manually. A `start` script keeps parity with the README's `npm install && npm run dev` workflow and matches community expectations for Next.js projects.
```suggestion
"dev": "next dev",
"build": "next build",
"start": "node .next/standalone/server.js"
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Adds a
nextjs-appexample: the smallest containerized Next.js app — one container, one page, one health route — available throughalien initand deployable to AWS, GCP, and Azure.Step-by-step flow when a user starts from this template:
alien init nextjs-appscaffolds the example into a new directory.alien releasebuilds the image from the included Dockerfile — Next.js standalone output, so the runtime image is justserver.jsand its traced files, nonode_modules. ← the heart: a plain web app shipped as a single containerThis PR changes the examples catalog from worker-style templates only to also covering a standard containerized web app.
What I did
examples/nextjs-app: App Router page +/api/healthroute, multi-stage Dockerfile,alien.tswith one Container (cpu 0.5,512Mi, port 3000, exposed over HTTP), pinned to the aws/gcp/azure platforms.examples/README.mdtable row, pnpm workspace member, and thealien initoffline fallback list.next devdirectly (hot reload); deploys go throughalien deploy.Files touched
examples/nextjs-app/**— the example (app code, Dockerfile,alien.ts, README, configs)examples/README.md,examples/pnpm-workspace.yaml— catalog row + workspace membercrates/alien-cli/src/commands/init.rs— one entry in theKNOWN_TEMPLATESfallback arrayHow I tested
pnpm exec next buildfrom the example compiles (/static,/api/healthdynamic). Released withalien release --platforms aws,gcp,azure→rel_94NtNCX9Z3Jk2cUjD1lIP8VxRJLF. Deployed that release to a test AWS account through a deployment link (CloudFormation, default-VPC network), waited forrunning, thencurl https://app.17opmt.vpc.direct/api/healthreturned{"status":"ok"}and the landing page served over HTTPS. Tore the deployment down after.cargo check -p alien-clifor the template entry;biome check examples/nextjs-appclean.